import { configToSearch, toSearchHandle } from '@/views/datacenter/business/utils/index'

export const importConfig = {
	tabSteps: [
		{
			label: '下载模板',
			download: '下载模板',
			active: 1,
			rules: [
				{
					label: '下载最新导入模板。共1个：',
					children: [
						{
							label: '《老人退院记录》',
							link: true,
							url: 'view_dpElderlyCheckoutRecord_downloadTemplate',
						},
					],
				},
			],
		},
		{
			label: '导入信息',
			description: '',
			uploadTip: '老人退院记录表',
			active: 2,
			url: 'view_dpElderlyCheckoutRecord_import',
			code: 3023,
			rules: [
				{
					label: '导入规则说明:',
					children: [
						{
							label: '(1)导入模式为“覆盖导入”，待导入的信息会覆盖平台已存在的',
						},
					],
				},
			],
		},
	],
	dataType: 95,
}

// 列表
const tableConfig = {
	stripe: true,
	border: true,
	maxHeight: '80vh',
	columns: [
		{ label: '养老机构', prop: 'organizationName' },
		{ label: '服务对象', prop: 'oldmanName' },
		{ label: '老人身份证号', prop: 'idCard', plusXing: '2,2' },
		{ label: '联系方式', prop: 'oldmanPhone', plusXing: '5,2' },
		{ label: '退院时间', prop: 'checkoutDate' },
		{ label: '退院原因', prop: 'checkoutReason' },
		{ label: '办理人姓名', prop: 'transactorName' },
		{ label: '办理时间', prop: 'transactDate' },
		{
			label: '是否可信',
			prop: 'isBelievable',
			custome: 'tag',
			dicData: [
				{ label: '否', value: 0, type: 'danger' },
				{ label: '是', value: 1, type: 'success' },
			],
		},
		{
			label: '操作',
			prop: 'menu',
			width: 280,
			fixed: 'right',
		},
	],
}

// 详情
export const detailConfig = {
	inline: false,
	showBtn: false,
	labelPosition: 'left',
	column: [
		{
			label: '养老机构',
			prop: 'organizationName',
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '养老机构统一信用代码',
			type: 'text',
			maxlength: '18',
			showWordLimit: true,
			prop: 'creditCode',
			span: 8,
		},
		{
			label: '服务对象',
			prop: 'oldmanName',
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '身份证号',
			prop: 'idCard',
			type: 'text',
			maxlength: '18',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '联系方式',
			prop: 'oldmanPhone',
			type: 'text',
			maxlength: '11',
			showWordLimit: true,
			span: 8,
		},

		{ label: '家属姓名', prop: 'familyName', span: 8 },
		{ label: '家属电话', prop: 'familyPhone', span: 8 },
		{ label: '家属身份证号码', prop: 'familyIdCard', span: 8 },
		{
			label: '退院原因',
			prop: 'checkoutReason',
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '退院时间',
			prop: 'checkoutDate',
			type: 'date',
			format: 'YYYY年MM月DD日',
			valueFormat: 'YYYY-MM-DD',
			span: 8,
		},

		{
			label: '办理人姓名',
			prop: 'transactorName',
			type: 'text',
			maxlength: '10',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '办理时间',
			prop: 'transactDate',
			type: 'date',
			format: 'YYYY年MM月DD日',
			valueFormat: 'YYYY-MM-DD',
			span: 8,
		},
		{
			label: '备注',
			prop: 'checkoutNote',
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
			span: 8,
		},
	],
}
const moreSearchConfig: any = {
	inline: true,
	showBtn: false,
	labelPosition: 'left',
	column: [...configToSearch(detailConfig.column)],
}
export const baseConfig = {
	pageName: '老人退院管理',
	// 数据字典
	dictcodes: [],
	rowKey: 'id',
	tipLabel: 'oldmanName',
	exportMqTopic: '/ning/export/',
	paramsObj: {
		code: 3023,
	},
	api: {
		moreSearch: 'view_dpElderlyCheckoutRecord_search',
		index: 'view_dpElderlyCheckoutRecord_page',
		delete: 'view_dpElderlyCheckoutRecord_del',
		edit: 'view_dpElderlyCheckoutRecord_edit',
		import: 'view_dpElderlyCheckoutRecord_import',
		export: 'view_dpElderlyCheckoutRecord_export',
	},
	auth: {
		index: 'view_dpElderlyCheckoutRecord_page',
		edit: 'view_dpElderlyCheckoutRecord_edit',
		delete: 'view_dpElderlyCheckoutRecord_del',
		import: 'view_dpElderlyCheckoutRecord_import',
		// export: 'view_dpElderlyCheckoutRecord_export',
		// 批量搜索
		mulitSet: 'mulitSet',
	},
	// 当前行操作按钮
	menuBtn: [
		{
			icon: 'detail',
			label: '查看',
			type: 'primary',
			operate: 'detail',
			auth: 'view_dpElderlyCheckoutRecord_page',
			text: true,
			show: true,
		},
		{
			icon: 'edit',
			label: '编辑',
			type: 'primary',
			operate: 'edit',
			auth: 'view_dpElderlyCheckoutRecord_page',
			text: true,
			show: true,
		},
		{
			icon: 'delete',
			label: '删除',
			type: 'danger',
			operate: 'delete',
			auth: 'view_dpElderlyCheckoutRecord_page',
			text: true,
			show: true,
		},
	],
	dialogConfig: {
		width: '80%',
	},
	moreSearchConfig,
	// 搜索
	searchConfig: {
		inline: true,
		showBtn: true,
		labelPosition: 'left',
		column: [
			{ label: '养老机构', prop: 'organizationName', type: 'input', span: 6 },
			{ label: '统一信用代码', prop: 'creditCode', type: 'input', span: 6 },
			{ label: '服务对象', prop: 'oldmanName', type: 'input', span: 6 },
			{ label: '身份证号', prop: 'idCard', type: 'input', span: 6 },
			{ label: '联系方式', prop: 'oldmanPhone', type: 'input', span: 6 },
			{
				label: '退院时间',
				prop: 'checkoutDateBetween',
				type: 'dateBetween',
				span: 6,
			},
			{
				label: '退院原因',
				prop: 'checkoutReason',
				type: 'input',
				span: 6,
			},
		],
	},
	importConfig,
	// 列表
	tableConfig,
	// 详情
	detailConfig,
	formConfig: {
		...detailConfig,
		showBtn: true,
	},
	beforeOnLoadFormate: async (params) => {
		params = toSearchHandle(moreSearchConfig, {}, params)
		return Promise.resolve({
			...params,
		})
	},
}
